home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 August / CICA - The Ultimate Collection of Shareware for Windows (Disc 2) (August 1995).iso / disc2 / demo / pwrtcp11.exe / TALK.FR_ / TALK.bin
Text File  |  1995-02-16  |  9KB  |  300 lines

  1. VERSION 2.00
  2. Begin Form frmTalk 
  3.    BackColor       =   &H8000000F&
  4.    Caption         =   "Talk"
  5.    ClientHeight    =   5820
  6.    ClientLeft      =   2148
  7.    ClientTop       =   1620
  8.    ClientWidth     =   7368
  9.    Height          =   6468
  10.    Icon            =   TALK.FRX:0000
  11.    Left            =   2100
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5820
  14.    ScaleWidth      =   7368
  15.    Top             =   1020
  16.    Width           =   7464
  17.    Begin PowerTCP_TCP TCPlisten 
  18.       Flags           =   0
  19.       Left            =   1620
  20.       LocalDotAddr    =   ""
  21.       OemLicense      =   ""
  22.       RemoteHost      =   ""
  23.       RemotePort      =   7
  24.       Top             =   900
  25.    End
  26.    Begin PowerTCP_TCP TCPconnect 
  27.       Flags           =   0
  28.       Left            =   360
  29.       LocalDotAddr    =   ""
  30.       OemLicense      =   ""
  31.       RemoteHost      =   ""
  32.       RemotePort      =   7
  33.       Top             =   900
  34.    End
  35.    Begin TextBox txtRecv 
  36.       Height          =   495
  37.       Left            =   1200
  38.       MultiLine       =   -1  'True
  39.       ScrollBars      =   2  'Vertical
  40.       TabIndex        =   1
  41.       Top             =   0
  42.       Width           =   1215
  43.    End
  44.    Begin TextBox txtSend 
  45.       Height          =   495
  46.       Left            =   0
  47.       MultiLine       =   -1  'True
  48.       ScrollBars      =   2  'Vertical
  49.       TabIndex        =   0
  50.       Top             =   0
  51.       Width           =   1215
  52.    End
  53.    Begin Menu mnuConversation 
  54.       Caption         =   "&Conversation"
  55.       Begin Menu mnuCListen 
  56.          Caption         =   "&Listen..."
  57.       End
  58.       Begin Menu mnuCStopListening 
  59.          Caption         =   "&Stop Listening"
  60.          Enabled         =   0   'False
  61.       End
  62.       Begin Menu mnuCSep1 
  63.          Caption         =   "-"
  64.       End
  65.       Begin Menu mnuCConnect 
  66.          Caption         =   "&Connect..."
  67.       End
  68.       Begin Menu mnuCDisconnect 
  69.          Caption         =   "&Disconnect"
  70.          Enabled         =   0   'False
  71.       End
  72.       Begin Menu mnuCSep2 
  73.          Caption         =   "-"
  74.       End
  75.       Begin Menu mnuCExit 
  76.          Caption         =   "E&xit"
  77.       End
  78.    End
  79.    Begin Menu mnuHelp 
  80.       Caption         =   "&Help"
  81.       Begin Menu mnuHHowToUse 
  82.          Caption         =   "&How to Use Talk"
  83.       End
  84.       Begin Menu mnuHSep 
  85.          Caption         =   "-"
  86.       End
  87.       Begin Menu mnuHelpAboutTalk 
  88.          Caption         =   "&About Talk..."
  89.       End
  90.    End
  91. End
  92.  
  93. ' This sample application is copyright 1994 by Dart
  94. ' Communications. All rights reserved.
  95. '
  96. ' You may use this application and any Visual Basic code
  97. ' within it for your own uses, and may modify it for your
  98. ' own needs.
  99.  
  100.  
  101. ' IMPORTANT: We MUST use the API MessageBox function
  102. ' instead of the VB MsgBox function. See the PowerTCP
  103. ' README for more information.
  104. Declare Function MessageBox Lib "User" (ByVal hWnd As Integer, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Integer) As Integer
  105.  
  106. Declare Sub ShellAbout Lib "SHELL.DLL" (ByVal hWnd As Integer, ByVal AppName As String, ByVal AppInfo As String, ByVal hIcon As Integer)
  107.  
  108. Const BorderWidth% = 30
  109.  
  110. ' Show parameters
  111. Const MODAL = 1
  112. Const MODELESS = 0
  113.  
  114. ' MsgBox parameters
  115. Const MB_OK = 0                 ' OK button only
  116.  
  117. Sub Form_Resize ()
  118.     On Error Resume Next    ' In case we get some kind
  119.                             ' of weird number because
  120.                             ' the form gets too small
  121.     
  122.     txtSend.Left = BorderWidth
  123.     txtSend.Top = BorderWidth
  124.     txtRecv.Top = BorderWidth
  125.  
  126.     txtSend.Height = ScaleHeight - 2 * BorderWidth
  127.     txtRecv.Height = txtSend.Height
  128.  
  129.     txtSend.Width = (ScaleWidth - 3 * BorderWidth) / 2
  130.     txtRecv.Width = txtSend.Width
  131.  
  132.     txtRecv.Left = txtSend.Width + 2 * BorderWidth
  133. End Sub
  134.  
  135. Sub Form_Unload (Cancel As Integer)
  136.     End
  137. End Sub
  138.  
  139. Sub mnuCConnect_Click ()
  140.     frmConnect.Show MODAL
  141.     
  142.     If frmConnect.Tag = True Then
  143.         tcpConnect.RemoteHost = frmConnect.txtHostName
  144.         tcpConnect.RemotePort = Val(frmConnect.txtPort)
  145.         tcpConnect.Action = CONNECT
  146.     End If
  147.  
  148.     frmConnect.Tag = ""
  149. End Sub
  150.  
  151. Sub mnuCDisconnect_Click ()
  152.     tcpConnect.Action = CLOSECOMM
  153. End Sub
  154.  
  155. Sub mnuCExit_Click ()
  156.     tcpListen.Action = ABORTCOMM
  157.     tcpConnect.Action = ABORTCOMM
  158.     End
  159. End Sub
  160.  
  161. Sub mnuCListen_Click ()
  162.     ' Hide the host name from the connect dialog
  163.     frmConnect.Label1.Visible = False
  164.     frmConnect.txtHostName.Visible = False
  165.  
  166.     frmConnect.Show MODAL
  167.     
  168.     If frmConnect.Tag = True Then
  169.         tcpListen.LocalPort = Val(frmConnect.txtPort)
  170.         tcpListen.Action = LISTEN
  171.     End If
  172.  
  173.     frmConnect.Label1.Visible = True
  174.     frmConnect.txtHostName.Visible = True
  175.     frmConnect.Tag = ""
  176. End Sub
  177.  
  178. Sub mnuCStopListening_Click ()
  179.     tcpListen.Action = CLOSECOMM
  180. End Sub
  181.  
  182. Sub mnuHelpAboutTalk_Click ()
  183.     ShellAbout Me.hWnd, "PowerTCP Talk Sample Application", "Talk Version 1.0 ⌐ 1994 Dart Communications" & Chr$(10) & "(315) 841-8106", Me.Icon
  184. End Sub
  185.  
  186. Sub mnuHHowToUse_Click ()
  187.     Msg$ = "To use Talk, first begin the Talk application"
  188.     Msg$ = Msg$ + " on one computer. Then click on Listen..."
  189.     Msg$ = Msg$ + " from the File menu, so that Talk"
  190.     Msg$ = Msg$ + " is listening on a certain port. Next,"
  191.     Msg$ = Msg$ + " begin Talk on another computer."
  192.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Talk: Page 1/3", 0)
  193.     Msg$ = "Choose Connect... from the File menu,"
  194.     Msg$ = Msg$ + " and fill in the computer name of the"
  195.     Msg$ = Msg$ + " first computer and the port it was"
  196.     Msg$ = Msg$ + " listening on."
  197.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Talk: Page 2/3", 0)
  198.     Msg$ = " Now both computers can communicate"
  199.     Msg$ = Msg$ + " by typing in the left text box."
  200.     Msg$ = Msg$ + " Whatever appears in the left text box"
  201.     Msg$ = Msg$ + " will also appear in the right text"
  202.     Msg$ = Msg$ + " box on the other computer." & Chr$(10)
  203.     Msg$ = Msg$ + Chr$(10) & "Choose Disconnect from"
  204.     Msg$ = Msg$ + " the File menu on either computer to"
  205.     Msg$ = Msg$ + " end the connection."
  206.     suc% = MessageBox(Me.hWnd, Msg$, "How to Use Talk: Page 3/3", 0)
  207. End Sub
  208.  
  209. Sub tcpConnect_Connect ()
  210.     mnuCConnect.Enabled = False
  211.     mnuCDisconnect.Enabled = True
  212. End Sub
  213.  
  214. Sub tcpConnect_Exception (ErrorCode As Integer, ErrorDesc As String)
  215.     If ErrorCode = PT_CLOSED Or ErrorCode = PT_ABORTED Then
  216.         suc% = MessageBox(Me.hWnd, "Connection to host lost", "Talk", MB_OK)
  217.  
  218.         mnuCConnect.Enabled = True
  219.         mnuCDisconnect.Enabled = False
  220.     Else
  221.         suc% = MessageBox(Me.hWnd, ErrorDesc & "(" & Format$(ErrorCode) & ").", "Talk", MB_OK)
  222.     
  223.         ' Destroy the connection
  224.         tcpConnect.Action = CLOSECOMM
  225.     End If
  226. End Sub
  227.  
  228. Sub tcpConnect_Recv (RecvData As String)
  229.     ' We have to check if any of the characters received
  230.     ' are carriage returns or backspaces, and process
  231.     ' them accordingly
  232.  
  233.     For i = 1 To Len(RecvData)
  234.         Select Case Mid$(RecvData, i, 1)
  235.         Case Chr$(13)           ' Carriage return
  236.             ' Even though only a Chr$(13) is sent, under
  237.             ' Windows a return is Chr$(13)+Chr$(10).
  238.             txtRecv = txtRecv & Chr$(13) & Chr$(10)
  239.         Case Chr$(8)            ' Backspace
  240.             txtRecv = Left$(txtRecv, Len(txtRecv) - 1)
  241.         Case Else               ' Normal
  242.             txtRecv = txtRecv + Mid$(RecvData, i, 1)
  243.         End Select
  244.     Next i
  245. End Sub
  246.  
  247. Sub tcpListen_Accept (NewSession As Long)
  248.     ' Only create a new session if no session currently
  249.     ' exists
  250.     
  251.     If tcpConnect.State = CLOSED Then
  252.         tcpConnect.Session = NewSession
  253.     Else
  254.         suc% = MessageBox(Me.hWnd, "Talk could not accept a new connection from a remote computer; only one at a time is allowed." & Chr$(10) & Chr$(10) & "If you are trying to connect to yourself, you must use two copies of Talk, and have one connect to the other.", "Connection Refused", 0)
  255.     End If
  256. End Sub
  257.  
  258. Sub tcpListen_Exception (ErrorCode As Integer, ErrorDesc As String)
  259.     If ErrorCode = PT_CLOSED Or ErrorCode = PT_ABORTED Then
  260.         suc% = MessageBox(Me.hWnd, "Listening stopped", "Talk", MB_OK)
  261.  
  262.         mnuCListen.Enabled = True
  263.         mnuCStopListening.Enabled = False
  264.     Else
  265.         suc% = MessageBox(Me.hWnd, ErrorDesc & "(" & Format$(ErrorCode) & ").", "Talk", MB_OK)
  266.         
  267.         ' Stop listening
  268.         tcpListen.Action = CLOSECOMM
  269.     End If
  270. End Sub
  271.  
  272. Sub tcpListen_Listen ()
  273.     mnuCListen.Enabled = False
  274.     mnuCStopListening.Enabled = True
  275. End Sub
  276.  
  277. Sub txtRecv_KeyPress (KeyAscii As Integer)
  278.     Msg$ = "To send text, type in the left box. The right"
  279.     Msg$ = Msg$ + " box is where all received text is"
  280.     Msg$ = Msg$ + " displayed."
  281.     suc% = MessageBox(Me.hWnd, Msg$, "Talk", 0)
  282.  
  283.     ' Prevent the character from appearing
  284.     KeyAscii = 0
  285.     
  286. End Sub
  287.  
  288. Sub txtSend_KeyPress (KeyAscii As Integer)
  289.     If tcpConnect.State = CONNECTED Then
  290.         ' Make sure the character appears at the end
  291.         txtSend.SelStart = Len(txtSend)
  292.  
  293.         tcpConnect.Send = Chr$(KeyAscii)
  294.     Else
  295.         ' Prevent the character from appearing
  296.         KeyAscii = 0
  297.     End If
  298. End Sub
  299.  
  300.